
class Solution {
public:

    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
        ListNode* act1=l1;
        ListNode* act2=l2;

        ListNode nummpy(0);

        ListNode* ret = &nummpy;
        int cur=0,jinwei=0;
        while(act1 || act2 || jinwei) {
            int digit1 = (act1 == nullptr)? 0: act1->val;
            int digit2 = (act2 == nullptr)? 0: act2->val;
            int total = jinwei + digit1 + digit2;

            cur = total%10;
            jinwei = total/10;
            ListNode* temp = new ListNode(cur);
            
           if(act1 != nullptr)
                act1 = act1->next;
            if(act2 != nullptr)
                act2 = act2->next;
             
            ret->next = temp;
            ret=ret->next;
        }

        return nummpy.next;
    }
};